package com.dao;

import com.pojo.ServiceMerchant;
import com.pojo.ServiceOrder;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ServiceOrderDao {

    @Insert("insert into service_order values (null,#{username},#{cid},#{iid},#{mid},#{content},#{appointmentTime},#{appointmentAddress},#{price},#{orderno},#{ordertime},#{status},#{contactmethod})" )
    public int add(ServiceOrder serviceOrder);
    @Results({
            @Result(id=true,property = "id",column = "id"),
            @Result(property = "serviceItem",column = "iid",javaType = ServiceMerchant.class,
                    one = @One(select = "com.dao.ServiceListDao.findById")),
            @Result(property = "serviceMerchant",column = "mid",javaType = ServiceMerchant.class,
                    one = @One(select = "com.dao.ServiceMerchantDao.findByMid"))
    })
    @Select("select * from service_order where username=#{username}")
    List<ServiceOrder> findAll(String username);
   @Update("update service_order set status=3 where id=#{id}")
    int updateById(Integer id);
    @Delete("delete from service_order where id=#{id}")
    int delById(Integer id);
}
